﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

namespace TendersParser
{
    public partial class Options : Form
    {
        XmlDocument xmlDoc;
        string ClassName;

        public Options(string className)
        {
            InitializeComponent();

            ClassName = className;
            xmlDoc = new XmlDocument();
            xmlDoc.Load("options.xml");
            XmlNode innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/thread_count");
            tbThreadNum.Text = innerNode.InnerText;
            innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/pages_from");
            tbPageNumberFrom.Text = innerNode.InnerText;
            innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/pages_to");
            tbPageNumberTo.Text = innerNode.InnerText;
            innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/delay");
            tbDelay.Text = innerNode.InnerText;
        }

        private void btnOptionsOK_Click(object sender, EventArgs e)
        {
            XmlNode innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/thread_count");
            innerNode.InnerText = tbThreadNum.Text;
            innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/pages_from");
            innerNode.InnerText = tbPageNumberFrom.Text;
            innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/pages_to");
            innerNode.InnerText = tbPageNumberTo.Text;
            innerNode = xmlDoc.SelectSingleNode("/options/" + ClassName + "/delay");
            innerNode.InnerText = tbDelay.Text;
            xmlDoc.Save("options.xml");
            this.Close();
        }
    }
}
